Requirement: Get all connections from dtsx packages using C#.
Solution:
Using Microsoft.SqlServer.Dts.Runtime to load the package, and then get all connections.
In case you are totally new to .Net/C#, you may need this screen capture:
In the pop-up window, click “Browse” tab, and select: C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Microsoft.SQLServer.ManagedDTS.dll
About the dll path:
ref 2: http://stackoverflow.com/questions/4920591/havent-got-microsoft-sqlserver-manageddts-dll-but
import: using Microsoft.SqlServer.Dts.Runtime
public void testDts() { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; pkgLocation = @"C:\Users\x\Documents\Visual Studio 2008\Projects\Integration Services Project1\Integration Services Project1\" + @"Package.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, null); Connections conns = pkg.Connections; foreach (ConnectionManager cm in conns) { Console.WriteLine("Name = " + cm.Name + ", HostType = " + cm.HostType + "; ConnectionString=" + cm.ConnectionString); } }
API: http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.package.connections(v=sql.100).aspx
Output:
Name = Flat File Connection Manager, HostType = ConnectionManager; ConnectionString=C:\Users\x\Desktop\ssisTest.txt
Name = x_instan, HostType = ConnectionManager; ConnectionString=Data Source=x-PC\x_INSTAN;Integrated Security=SSPI;Connect Timeout=30;
Grails: generate-all Class Error: No domain class found for name “Class” <->
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.